package qldc.pm.tienan.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import qldc.pm.tienan.service.BienBanBanGiaoHoSoLocalServiceUtil;
import qldc.pm.tienan.service.ClpSerializer;

import java.io.Serializable;

import java.lang.reflect.Method;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;


public class BienBanBanGiaoHoSoClp extends BaseModelImpl<BienBanBanGiaoHoSo>
    implements BienBanBanGiaoHoSo {
    private long _bienBanBanGiaoHoSoId;
    private String _kinhGui;
    private String _nguoiLap;
    private String _nguoiDuocBanGiao;
    private String _chucVu;
    private String _chucVuNguoiDuocBanGiao;
    private String _noiDung;
    private Date _ngayLap;
    private Date _ngayBanGiao;
    private String _diaDiemBanGiao;
    private BaseModel<?> _bienBanBanGiaoHoSoRemoteModel;

    public BienBanBanGiaoHoSoClp() {
    }

    @Override
    public Class<?> getModelClass() {
        return BienBanBanGiaoHoSo.class;
    }

    @Override
    public String getModelClassName() {
        return BienBanBanGiaoHoSo.class.getName();
    }

    @Override
    public long getPrimaryKey() {
        return _bienBanBanGiaoHoSoId;
    }

    @Override
    public void setPrimaryKey(long primaryKey) {
        setBienBanBanGiaoHoSoId(primaryKey);
    }

    @Override
    public Serializable getPrimaryKeyObj() {
        return _bienBanBanGiaoHoSoId;
    }

    @Override
    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    @Override
    public Map<String, Object> getModelAttributes() {
        Map<String, Object> attributes = new HashMap<String, Object>();

        attributes.put("bienBanBanGiaoHoSoId", getBienBanBanGiaoHoSoId());
        attributes.put("kinhGui", getKinhGui());
        attributes.put("nguoiLap", getNguoiLap());
        attributes.put("nguoiDuocBanGiao", getNguoiDuocBanGiao());
        attributes.put("chucVu", getChucVu());
        attributes.put("chucVuNguoiDuocBanGiao", getChucVuNguoiDuocBanGiao());
        attributes.put("noiDung", getNoiDung());
        attributes.put("ngayLap", getNgayLap());
        attributes.put("ngayBanGiao", getNgayBanGiao());
        attributes.put("diaDiemBanGiao", getDiaDiemBanGiao());

        return attributes;
    }

    @Override
    public void setModelAttributes(Map<String, Object> attributes) {
        Long bienBanBanGiaoHoSoId = (Long) attributes.get(
                "bienBanBanGiaoHoSoId");

        if (bienBanBanGiaoHoSoId != null) {
            setBienBanBanGiaoHoSoId(bienBanBanGiaoHoSoId);
        }

        String kinhGui = (String) attributes.get("kinhGui");

        if (kinhGui != null) {
            setKinhGui(kinhGui);
        }

        String nguoiLap = (String) attributes.get("nguoiLap");

        if (nguoiLap != null) {
            setNguoiLap(nguoiLap);
        }

        String nguoiDuocBanGiao = (String) attributes.get("nguoiDuocBanGiao");

        if (nguoiDuocBanGiao != null) {
            setNguoiDuocBanGiao(nguoiDuocBanGiao);
        }

        String chucVu = (String) attributes.get("chucVu");

        if (chucVu != null) {
            setChucVu(chucVu);
        }

        String chucVuNguoiDuocBanGiao = (String) attributes.get(
                "chucVuNguoiDuocBanGiao");

        if (chucVuNguoiDuocBanGiao != null) {
            setChucVuNguoiDuocBanGiao(chucVuNguoiDuocBanGiao);
        }

        String noiDung = (String) attributes.get("noiDung");

        if (noiDung != null) {
            setNoiDung(noiDung);
        }

        Date ngayLap = (Date) attributes.get("ngayLap");

        if (ngayLap != null) {
            setNgayLap(ngayLap);
        }

        Date ngayBanGiao = (Date) attributes.get("ngayBanGiao");

        if (ngayBanGiao != null) {
            setNgayBanGiao(ngayBanGiao);
        }

        String diaDiemBanGiao = (String) attributes.get("diaDiemBanGiao");

        if (diaDiemBanGiao != null) {
            setDiaDiemBanGiao(diaDiemBanGiao);
        }
    }

    @Override
    public long getBienBanBanGiaoHoSoId() {
        return _bienBanBanGiaoHoSoId;
    }

    @Override
    public void setBienBanBanGiaoHoSoId(long bienBanBanGiaoHoSoId) {
        _bienBanBanGiaoHoSoId = bienBanBanGiaoHoSoId;

        if (_bienBanBanGiaoHoSoRemoteModel != null) {
            try {
                Class<?> clazz = _bienBanBanGiaoHoSoRemoteModel.getClass();

                Method method = clazz.getMethod("setBienBanBanGiaoHoSoId",
                        long.class);

                method.invoke(_bienBanBanGiaoHoSoRemoteModel,
                    bienBanBanGiaoHoSoId);
            } catch (Exception e) {
                throw new UnsupportedOperationException(e);
            }
        }
    }

    @Override
    public String getKinhGui() {
        return _kinhGui;
    }

    @Override
    public void setKinhGui(String kinhGui) {
        _kinhGui = kinhGui;

        if (_bienBanBanGiaoHoSoRemoteModel != null) {
            try {
                Class<?> clazz = _bienBanBanGiaoHoSoRemoteModel.getClass();

                Method method = clazz.getMethod("setKinhGui", String.class);

                method.invoke(_bienBanBanGiaoHoSoRemoteModel, kinhGui);
            } catch (Exception e) {
                throw new UnsupportedOperationException(e);
            }
        }
    }

    @Override
    public String getNguoiLap() {
        return _nguoiLap;
    }

    @Override
    public void setNguoiLap(String nguoiLap) {
        _nguoiLap = nguoiLap;

        if (_bienBanBanGiaoHoSoRemoteModel != null) {
            try {
                Class<?> clazz = _bienBanBanGiaoHoSoRemoteModel.getClass();

                Method method = clazz.getMethod("setNguoiLap", String.class);

                method.invoke(_bienBanBanGiaoHoSoRemoteModel, nguoiLap);
            } catch (Exception e) {
                throw new UnsupportedOperationException(e);
            }
        }
    }

    @Override
    public String getNguoiDuocBanGiao() {
        return _nguoiDuocBanGiao;
    }

    @Override
    public void setNguoiDuocBanGiao(String nguoiDuocBanGiao) {
        _nguoiDuocBanGiao = nguoiDuocBanGiao;

        if (_bienBanBanGiaoHoSoRemoteModel != null) {
            try {
                Class<?> clazz = _bienBanBanGiaoHoSoRemoteModel.getClass();

                Method method = clazz.getMethod("setNguoiDuocBanGiao",
                        String.class);

                method.invoke(_bienBanBanGiaoHoSoRemoteModel, nguoiDuocBanGiao);
            } catch (Exception e) {
                throw new UnsupportedOperationException(e);
            }
        }
    }

    @Override
    public String getChucVu() {
        return _chucVu;
    }

    @Override
    public void setChucVu(String chucVu) {
        _chucVu = chucVu;

        if (_bienBanBanGiaoHoSoRemoteModel != null) {
            try {
                Class<?> clazz = _bienBanBanGiaoHoSoRemoteModel.getClass();

                Method method = clazz.getMethod("setChucVu", String.class);

                method.invoke(_bienBanBanGiaoHoSoRemoteModel, chucVu);
            } catch (Exception e) {
                throw new UnsupportedOperationException(e);
            }
        }
    }

    @Override
    public String getChucVuNguoiDuocBanGiao() {
        return _chucVuNguoiDuocBanGiao;
    }

    @Override
    public void setChucVuNguoiDuocBanGiao(String chucVuNguoiDuocBanGiao) {
        _chucVuNguoiDuocBanGiao = chucVuNguoiDuocBanGiao;

        if (_bienBanBanGiaoHoSoRemoteModel != null) {
            try {
                Class<?> clazz = _bienBanBanGiaoHoSoRemoteModel.getClass();

                Method method = clazz.getMethod("setChucVuNguoiDuocBanGiao",
                        String.class);

                method.invoke(_bienBanBanGiaoHoSoRemoteModel,
                    chucVuNguoiDuocBanGiao);
            } catch (Exception e) {
                throw new UnsupportedOperationException(e);
            }
        }
    }

    @Override
    public String getNoiDung() {
        return _noiDung;
    }

    @Override
    public void setNoiDung(String noiDung) {
        _noiDung = noiDung;

        if (_bienBanBanGiaoHoSoRemoteModel != null) {
            try {
                Class<?> clazz = _bienBanBanGiaoHoSoRemoteModel.getClass();

                Method method = clazz.getMethod("setNoiDung", String.class);

                method.invoke(_bienBanBanGiaoHoSoRemoteModel, noiDung);
            } catch (Exception e) {
                throw new UnsupportedOperationException(e);
            }
        }
    }

    @Override
    public Date getNgayLap() {
        return _ngayLap;
    }

    @Override
    public void setNgayLap(Date ngayLap) {
        _ngayLap = ngayLap;

        if (_bienBanBanGiaoHoSoRemoteModel != null) {
            try {
                Class<?> clazz = _bienBanBanGiaoHoSoRemoteModel.getClass();

                Method method = clazz.getMethod("setNgayLap", Date.class);

                method.invoke(_bienBanBanGiaoHoSoRemoteModel, ngayLap);
            } catch (Exception e) {
                throw new UnsupportedOperationException(e);
            }
        }
    }

    @Override
    public Date getNgayBanGiao() {
        return _ngayBanGiao;
    }

    @Override
    public void setNgayBanGiao(Date ngayBanGiao) {
        _ngayBanGiao = ngayBanGiao;

        if (_bienBanBanGiaoHoSoRemoteModel != null) {
            try {
                Class<?> clazz = _bienBanBanGiaoHoSoRemoteModel.getClass();

                Method method = clazz.getMethod("setNgayBanGiao", Date.class);

                method.invoke(_bienBanBanGiaoHoSoRemoteModel, ngayBanGiao);
            } catch (Exception e) {
                throw new UnsupportedOperationException(e);
            }
        }
    }

    @Override
    public String getDiaDiemBanGiao() {
        return _diaDiemBanGiao;
    }

    @Override
    public void setDiaDiemBanGiao(String diaDiemBanGiao) {
        _diaDiemBanGiao = diaDiemBanGiao;

        if (_bienBanBanGiaoHoSoRemoteModel != null) {
            try {
                Class<?> clazz = _bienBanBanGiaoHoSoRemoteModel.getClass();

                Method method = clazz.getMethod("setDiaDiemBanGiao",
                        String.class);

                method.invoke(_bienBanBanGiaoHoSoRemoteModel, diaDiemBanGiao);
            } catch (Exception e) {
                throw new UnsupportedOperationException(e);
            }
        }
    }

    public BaseModel<?> getBienBanBanGiaoHoSoRemoteModel() {
        return _bienBanBanGiaoHoSoRemoteModel;
    }

    public void setBienBanBanGiaoHoSoRemoteModel(
        BaseModel<?> bienBanBanGiaoHoSoRemoteModel) {
        _bienBanBanGiaoHoSoRemoteModel = bienBanBanGiaoHoSoRemoteModel;
    }

    public Object invokeOnRemoteModel(String methodName,
        Class<?>[] parameterTypes, Object[] parameterValues)
        throws Exception {
        Object[] remoteParameterValues = new Object[parameterValues.length];

        for (int i = 0; i < parameterValues.length; i++) {
            if (parameterValues[i] != null) {
                remoteParameterValues[i] = ClpSerializer.translateInput(parameterValues[i]);
            }
        }

        Class<?> remoteModelClass = _bienBanBanGiaoHoSoRemoteModel.getClass();

        ClassLoader remoteModelClassLoader = remoteModelClass.getClassLoader();

        Class<?>[] remoteParameterTypes = new Class[parameterTypes.length];

        for (int i = 0; i < parameterTypes.length; i++) {
            if (parameterTypes[i].isPrimitive()) {
                remoteParameterTypes[i] = parameterTypes[i];
            } else {
                String parameterTypeName = parameterTypes[i].getName();

                remoteParameterTypes[i] = remoteModelClassLoader.loadClass(parameterTypeName);
            }
        }

        Method method = remoteModelClass.getMethod(methodName,
                remoteParameterTypes);

        Object returnValue = method.invoke(_bienBanBanGiaoHoSoRemoteModel,
                remoteParameterValues);

        if (returnValue != null) {
            returnValue = ClpSerializer.translateOutput(returnValue);
        }

        return returnValue;
    }

    @Override
    public void persist() throws SystemException {
        if (this.isNew()) {
            BienBanBanGiaoHoSoLocalServiceUtil.addBienBanBanGiaoHoSo(this);
        } else {
            BienBanBanGiaoHoSoLocalServiceUtil.updateBienBanBanGiaoHoSo(this);
        }
    }

    @Override
    public BienBanBanGiaoHoSo toEscapedModel() {
        return (BienBanBanGiaoHoSo) ProxyUtil.newProxyInstance(BienBanBanGiaoHoSo.class.getClassLoader(),
            new Class[] { BienBanBanGiaoHoSo.class },
            new AutoEscapeBeanHandler(this));
    }

    @Override
    public Object clone() {
        BienBanBanGiaoHoSoClp clone = new BienBanBanGiaoHoSoClp();

        clone.setBienBanBanGiaoHoSoId(getBienBanBanGiaoHoSoId());
        clone.setKinhGui(getKinhGui());
        clone.setNguoiLap(getNguoiLap());
        clone.setNguoiDuocBanGiao(getNguoiDuocBanGiao());
        clone.setChucVu(getChucVu());
        clone.setChucVuNguoiDuocBanGiao(getChucVuNguoiDuocBanGiao());
        clone.setNoiDung(getNoiDung());
        clone.setNgayLap(getNgayLap());
        clone.setNgayBanGiao(getNgayBanGiao());
        clone.setDiaDiemBanGiao(getDiaDiemBanGiao());

        return clone;
    }

    @Override
    public int compareTo(BienBanBanGiaoHoSo bienBanBanGiaoHoSo) {
        int value = 0;

        if (getBienBanBanGiaoHoSoId() < bienBanBanGiaoHoSo.getBienBanBanGiaoHoSoId()) {
            value = -1;
        } else if (getBienBanBanGiaoHoSoId() > bienBanBanGiaoHoSo.getBienBanBanGiaoHoSoId()) {
            value = 1;
        } else {
            value = 0;
        }

        value = value * -1;

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (!(obj instanceof BienBanBanGiaoHoSoClp)) {
            return false;
        }

        BienBanBanGiaoHoSoClp bienBanBanGiaoHoSo = (BienBanBanGiaoHoSoClp) obj;

        long primaryKey = bienBanBanGiaoHoSo.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(21);

        sb.append("{bienBanBanGiaoHoSoId=");
        sb.append(getBienBanBanGiaoHoSoId());
        sb.append(", kinhGui=");
        sb.append(getKinhGui());
        sb.append(", nguoiLap=");
        sb.append(getNguoiLap());
        sb.append(", nguoiDuocBanGiao=");
        sb.append(getNguoiDuocBanGiao());
        sb.append(", chucVu=");
        sb.append(getChucVu());
        sb.append(", chucVuNguoiDuocBanGiao=");
        sb.append(getChucVuNguoiDuocBanGiao());
        sb.append(", noiDung=");
        sb.append(getNoiDung());
        sb.append(", ngayLap=");
        sb.append(getNgayLap());
        sb.append(", ngayBanGiao=");
        sb.append(getNgayBanGiao());
        sb.append(", diaDiemBanGiao=");
        sb.append(getDiaDiemBanGiao());
        sb.append("}");

        return sb.toString();
    }

    @Override
    public String toXmlString() {
        StringBundler sb = new StringBundler(34);

        sb.append("<model><model-name>");
        sb.append("qldc.pm.tienan.model.BienBanBanGiaoHoSo");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>bienBanBanGiaoHoSoId</column-name><column-value><![CDATA[");
        sb.append(getBienBanBanGiaoHoSoId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>kinhGui</column-name><column-value><![CDATA[");
        sb.append(getKinhGui());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>nguoiLap</column-name><column-value><![CDATA[");
        sb.append(getNguoiLap());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>nguoiDuocBanGiao</column-name><column-value><![CDATA[");
        sb.append(getNguoiDuocBanGiao());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>chucVu</column-name><column-value><![CDATA[");
        sb.append(getChucVu());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>chucVuNguoiDuocBanGiao</column-name><column-value><![CDATA[");
        sb.append(getChucVuNguoiDuocBanGiao());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>noiDung</column-name><column-value><![CDATA[");
        sb.append(getNoiDung());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>ngayLap</column-name><column-value><![CDATA[");
        sb.append(getNgayLap());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>ngayBanGiao</column-name><column-value><![CDATA[");
        sb.append(getNgayBanGiao());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>diaDiemBanGiao</column-name><column-value><![CDATA[");
        sb.append(getDiaDiemBanGiao());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
